import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;


public class SerializationExample {
    public static void main(String[] args) {

        try (ObjectOutputStream objectOutputStream = new ObjectOutputStream
                (new FileOutputStream("person.ser"))) {
            Person person = new Person("明志", 12);
            objectOutputStream.writeObject(person);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
